/*
 * @Author: szx
 * @Date: 2021-10-29 11:40:29
 * @LastEditTime: 2021-10-29 11:50:13
 * @Description:
 * @FilePath: \leetcode\557\557.cpp
 */
#include <iostream>
#include <vector>
using namespace std;
class Solution {
   public:
    string reverseWords(string s) {
        int l = 0, r = 0;
        while (r < s.length()) {
            if (s[++r] == ' ' || r == s.length()) {
                int x = r - 1;
                while (x > l) {
                    swap(s[l++], s[x--]);
                }
                l = r + 1;
            }
        }
        return s;
    }
};
int main() { return 0; }